import Vue from "vue";
// 导入路由
import VueRouter from "vue-router";

import Home from "../views/home/index.vue";
import Order from "../views/order/index.vue";
import City from "../views/city/index.vue";
import Kind from "../views/kind/index.vue";
import Cart from "../views/cart/index.vue";
import User from "../views/user/index.vue";
import Detail from "../views/detail/index.vue";

// import Error from "../views/error/index.vue";

Vue.use(VueRouter);

// 路由规则
const routes = [
  {
    path: "/", // 路由的重定向
    redirect: "/home",
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
  },

  {
    path: "/kind",
    name: "Kind",
    component: Kind,
  },
  {
    path: "/cart",
    name: "Cart",
    component: Cart,
    // 路由元信息
    // 不显示底部四个按钮，选项卡
    meta: {
      hidden: true,
    },
  },
  {
    path: "/order/:time",
    component: Order,
    // 路由元信息
    // 不显示底部四个按钮，选项卡
    meta: {
      hidden: true,
    },
  },
  {
    path: "/addlist/:time",
    name: "addlist",
    // 路由元信息
    // 不显示底部四个按钮，选项卡
    meta: {
      hidden: true,
    },
    component: () =>
      import(/* webpackChunkName: "addlist" */ "../views/order/addlist.vue"),
  },
  {
    path: "/addnew/:time",
    name: "addnew",
    // 路由元信息
    // 不显示底部四个按钮，选项卡
    meta: {
      hidden: true,
    },
    component: () =>
      import(/* webpackChunkName: "addnew" */ "../views/order/addnew.vue"),
  },
  {
    path: "/city",
    component: City,
    meta: {
      hidden: true,
    },
  },
  {
    path: "/user",
    name: "User",
    component: User,
  },
  //   搜索
  {
    path: "/search",
    name: "search",
    meta: {
      hidden: true,
    },
    component: () =>
      import(/* webpackChunkName: "search" */ "../views/search/index.vue"),
  },
  //   结果
  {
    path: "/result/:keyword",
    name: "result",
    meta: {
      hidden: true,
    },
    component: () =>
      import(/* webpackChunkName: "result" */ "../views/search/result.vue"),
  },
  // 登录
  {
    path: "/login",
    name: "login",
    meta: {
      hidden: true,
    },
    component: () =>
      import(/* webpackChunkName: "login" */ "../views/login/index.vue"),
  },
  {
    path: "/detail/:proid", // 带有参数的路由
    name: "Detail",
    // 路由元信息
    // 不显示底部四个按钮，选项卡
    meta: {
      hidden: true,
    },
    // 对于 详情我们 要使用路由懒加载的方式
    component: () =>
      import(/* webpackChunkName: "detail" */ "../views/detail/index.vue"),
  },
  {
    path: "/register", // 带有参数的路由
    name: "Register",
    // 路由元信息
    // 不显示底部四个按钮，选项卡
    meta: {
      hidden: true,
    },
    // 对于 详情我们 要使用路由懒加载的方式
    component: () =>
      import(/* webpackChunkName: "register" */ "../views/register/index.vue"),
    children: [
      {
        path: "step1",
        component: () =>
          import(
            /* webpackChunkName: "register" */ "../views/register/step1.vue"
          ),
      },
      {
        path: "step2",
        component: () =>
          import(
            /* webpackChunkName: "register" */ "../views/register/step2.vue"
          ),
      },
      {
        path: "step3",
        component: () =>
          import(
            /* webpackChunkName: "register" */ "../views/register/step3.vue"
          ),
      },
    ],
  },
  {
    path: "*",
    // 对于 404 页面我们 要使用路由懒加载的方式
    // component: Error
    component: () =>
      import(/* webpackChunkName: "error404" */ "../views/error/index.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
